package com.netty.demo10;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * Created by Lxk on 2020/1/31.
 */
public class NioTest2 {

    public static void main(String[] args) throws Exception {
        FileInputStream fileInputStream = new FileInputStream("NioTest2.txt");
        FileChannel channel = fileInputStream.getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(512);
        channel.read(buffer);
        buffer.flip();
        while(buffer.remaining()>0){
            byte b = buffer.get();
            System.out.println("Character: " + (char)b);
        }
        fileInputStream.close();
    }

}
